#include<iostream>
#include<vector>
#include<unordered_set>
using namespace std;

class Solution {
public:
	int findPairs(vector<int>& nums, int k) {
		if (k < 0)return 0;
		unordered_set<int> a;
		unordered_set<int> b;
		int count = 0;
		for (int m:nums)
		{
			auto s=a.insert(m);
			if (k == 0&& s.second==false) 
			{
				b.insert(m);
			}
		}
		if (k == 0) return b.size();
		for (int m:a)
		{
			auto result=a.find(m + k);
			if (result != a.end()) count++;
		}
		
		return count;
	}
};

//int main()
//{
//	Solution *s = new Solution;
//	vector<int> a = { 1,1,1,1,1,};
//	s->findPairs(a,0);
//	return 0;
//}